<!DOCTYPE html>
<HTML>
<head>
    <title>用户登录</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" th:href="@{/jquery-weui/lib/weui.css}">
    <link rel="stylesheet" th:href="@{/jquery-weui/css/jquery-weui.css}">
    <style>
        body, html {
            height: 100%;
            margin: 0;
        }
        .container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100%;
        }
    </style>
</head>
<body>
<div class="container">
    <div>
        <a class="weui-btn weui-btn_primary btn-css" href="javascript:" onclick="wxdl();">微信授权登录</a>
    </div>
</div>
</body>
<script type="text/javascript" th:src="@{/jquery-weui/lib/jquery-2.1.4.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/lib/fastclick.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/js/jquery-weui.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/crypto-js.min.js?t=1}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/com.js}" charset="utf-8"></script>
<script type="text/javascript">
    //后端地址
    var url = "[[${serverUrl}]]/stamp/h5/api/";
    //回跳地址
    var backurl = "[[${backurl}]]";
    function wxdl(){
        $.showLoading("登录中...");
        var jsonData = {
            backurl: backurl,
            timestamp:new Date().getTime()
        };
        $.ajax({
            type:"post",
            url:url+"login",
            dataType:"json",
            timeout : 10*1000, //超时时间设置，单位毫秒
            crossDomain: true,
            data:JSON.stringify(jsonData),
            contentType: 'application/json;charset=UTF-8',
            beforeSend: function(request) {
                request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
            },
            success:function(result){
                if (result.code==0){
                    window.location.href=result.data;

                }else{
                    alert("登录发生错误！");
                }
            },
            error:function(result){
                alert("登录发生错误！");
            },complete:function(){
                $.hideLoading();
            }
        });
    }

    wxdl();
</script>
</html>